
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>修改讲座</title>
<link rel="stylesheet" href='css/style.css' type="text/css">
</head>
<script type="text/javascript" src="js/WdatePicker.js"></script>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript' src='js/public.js'></script>
<script type="text/javascript">
	function showuserkey() {
		var params = "user_keyName=userName&user_keyName=privilegeToCreateLecture";
		new Ajax.Request("json/showUser_key", {
			method : "post",
			parameters : params,
			onComplete : function(request) {
				var res = request.responseText.evalJSON();

				if (res["result"]["userName"] == null
						|| res["result"]["privilegeToCreateLecture"] == "0")
					window.location.href = "login.html";
				document.getElementById("username").innerHTML = "欢迎 "
						+ res["result"]["userName"];
			},
			asynchronous : true
		});
		online();
		showlecture();
	}
	
	
	function showlecture() {

		var request = {
			QueryString : function(val) {
				var uri = window.location.search;
				var re = new RegExp("" + val + "=([^&?]*)", "ig");
				return ((uri.match(re)) ? (uri.match(re)[0]
						.substr(val.length + 1)) : null);
			}
		};
		var lectureId = request.QueryString("lectureId");
		var params = "lectureId=" + lectureId;

		new Ajax.Request(
				"json/viewLecturesOutline",
				{
					method : "post",
					parameters : params,
					onComplete : function(request) {
						var res = request.responseText.evalJSON();

						
						if (res["result"]["flag"] == "true") {
							var str=res["result"]["lecYear"];
							var lecyear1 = str.substr(0,4);
							　　 str = str.replace(lecyear1,'');
						    var lecyear2=str.substr(0,4);
							    str = str.replace(lecyear2,'');
							var lecterm=str.substr(0,1);
							document.getElementById("lecyear1").value = lecyear1;
							document.getElementById("lecyear2").value = lecyear2;
							document.getElementById("lecterm").value = lecterm;
							document.getElementById("name").value = res["result"]["lecName"];
							document.getElementById("who").value = res["result"]["lecSpeaker"];
							document.getElementById("lectime").value = res["result"]["lecTime"];
							document.getElementById("place").value = res["result"]["lecPlace"];
							document.getElementById("tinumber").value = res["result"]["lecCodeNumber"];
							document.getElementById("starttime").value = res["result"]["startTime"];
							document.getElementById("stoptime").value = res["result"]["stopTime"];
							document.getElementById("grade1").value = res["result"]["userEnterYear1"];
							document.getElementById("grade2").value = res["result"]["userEnterYear2"];
							document.getElementById("grade3").value = res["result"]["userEnterYear3"];
							document.getElementById("grade4").value = res["result"]["userEnterYear4"];
                                                        document.getElementById("lecNote").value = res["result"]["lecNote"];

						}
					},
					asynchronous : false
				});
	}

	function sdf() {
		var request = {
			QueryString : function(val) {
				var uri = window.location.search;
				var re = new RegExp("" + val + "=([^&?]*)", "ig");
				return ((uri.match(re)) ? (uri.match(re)[0]
						.substr(val.length + 1)) : null);
			}
		};
		var lId = request.QueryString("lectureId");

		var lecName = document.getElementById("name").value;
                  var lecNote = document.getElementById("lecNote").value;
		var lecSpeaker = document.getElementById("who").value;
		var lecTime = document.getElementById("lectime").value;
		var lecPlace = document.getElementById("place").value;
		var lecCodeNumber = document.getElementById("tinumber").value;
		var startTime = document.getElementById("starttime").value;
		var stopTime = document.getElementById("stoptime").value;
		var userEnterYear1 = document.getElementById("grade1").value;
		var userEnterYear2 = document.getElementById("grade2").value;
		var userEnterYear3 = document.getElementById("grade3").value;
		var userEnterYear4 = document.getElementById("grade4").value;
		var year1 = document.getElementById("lecyear1").value;
		var year2 = document.getElementById("lecyear2").value;
		var lecterm = document.getElementById("lecterm").value;
		var lecyear = year1 + year2 + lecterm;
		if (lecName == "" || lecCodeNumber == "" || startTime == ""
				|| stopTime == "" || year1 == "" || year2 == ""
				|| lecterm == "" || userEnterYear1 == "") {
			alert("请输入必要信息！");
		} else {
			var params = "lectureId="
					+ lId
					+ "&lecCodeNumber="
					+ lecCodeNumber
					+ "&Lecture_keyName=lecName&Lecture_keyName=lecSpeaker&Lecture_keyName=lecTime&Lecture_keyName=lecPlace&Lecture_keyName=lecCodeNumber&Lecture_keyName=startTime&Lecture_keyName=stopTime&Lecture_keyName=userEnterYear1&Lecture_keyName=userEnterYear2&Lecture_keyName=userEnterYear3&Lecture_keyName=userEnterYear4&Lecture_keyName=lecYear&Lecture_keyName=lecNote&Lecture_keyValue="
					+ encodeURIComponent(lecName) + "&Lecture_keyValue="
					+ encodeURIComponent(lecSpeaker) + "&Lecture_keyValue="
					+ encodeURIComponent(lecTime) + "&Lecture_keyValue="
					+ encodeURIComponent(lecPlace) + "&Lecture_keyValue="
					+ encodeURIComponent(lecCodeNumber) + "&Lecture_keyValue="
					+ encodeURIComponent(startTime) + "&Lecture_keyValue="
					+ encodeURIComponent(stopTime) + "&Lecture_keyValue="
					+ encodeURIComponent(userEnterYear1) + "&Lecture_keyValue="
					+ encodeURIComponent(userEnterYear2) + "&Lecture_keyValue="
					+ encodeURIComponent(userEnterYear3) + "&Lecture_keyValue="
					+ encodeURIComponent(userEnterYear4) + "&Lecture_keyValue="
					+ encodeURIComponent(lecyear)+ "&Lecture_keyValue="
					+ encodeURIComponent(lecNote);

			new Ajax.Request("json/altLecture", {
				method : "post",
				parameters : params,
				onComplete : function(request) {

					var res = request.responseText.evalJSON();

					if (res["result"]["flag"] == "true") {
						alert("已成功修改！");
						window.location.href = "TeacherIndex.html";
					} else {
						alert("验证码已重新生成");
						window.location.href = "TeacherIndex.html";

					}

				},
				asynchronous : true
			});
		}
	}
</script>
<body onload="showuserkey()">

	<div id="header">

		<div id="nav">
			<ul
				style="float: left; padding: 0 20px; text-align: center; line-height: 50px;">
				<li style="float: left; font-size: 28px">经管院学术讲坛事务系统</li>
			</ul>
			<ul class="horizon">

				<li class="login">
					<ul class="vertical">
						<li class="userInfo" id="username">&nbsp;你好</li>
						<li class="userInfo2">
							<ul class="horizon">

								<li><a href="adminUser.html" target="_blank"
									style="text-decoration: none;">用户信息管理</a><br /> <a
									onclick="outline()" style="text-decoration: none;" href="#">注销</a></li>
							</ul>
						</li>
					</ul>
				</li>

			</ul>
		</div>




	</div>
	<div id="main">
		<div
			style="width: 21%; height: 700px; border-right: 3px #660033 solid; float: left; background-color: rgb(242, 247, 252);"></div>
		<div style="width: 78%; font-size: 20px; float: right">
			<div style="margin-top: 80px; margin-left: 250px; height: 600px">
				<form method="post" style="font-size: 18px">
					讲座名称<br> <input type="text" name="name" id="name" style="height: 25px; background:none; border:1px solid #CCC"/><br>
					主讲人<br> <input type="text" name="who" id="who" style="height: 25px; background:none; border:1px solid #CCC"/><br>
					讲座时间<br> <input type="text" name="lectime" id="lectime" style="height: 25px; background:none; border:1px solid #CCC"/><br>
					讲座地点<br> <input type="text" name="place" id="place" style="height: 25px; background:none; border:1px solid #CCC"/><br>
					所属学期<br> <input style="height: 25px; background:none; border:1px solid #CCC" name="lecyear1" type="text" id="lecyear1"
						onclick="WdatePicker({dateFmt:'yyyy'})">-- <input style="height: 25px; background:none; border:1px solid #CCC"
						name="lecyear2" type="text" id="lecyear2"
						onclick="WdatePicker({dateFmt:'yyyy'})"> <select
						name="lecterm" id="lecterm" style="height: 25px; background:none; border:1px solid #CCC">
						<option value="1">第一学期</option>
						<option value="2">第二学期</option>

					</select><br> 发放票数<br> <input name="tinumber" type="text"
						id="tinumber" value="0" style="height: 25px; background:none; border:1px solid #CCC"/><br> 参与年级<br> <input
						name="grade1" style="height: 25px; background:none; border:1px solid #CCC" type="text" id="grade1"
						onclick="WdatePicker({dateFmt:'yyyy'})"> <input
						name="grade2" style="height: 25px; background:none; border:1px solid #CCC" type="text" id="grade2"
						onclick="WdatePicker({dateFmt:'yyyy'})"> <input
						name="grade3" style="height: 25px; background:none; border:1px solid #CCC" type="text" id="grade3"
						onclick="WdatePicker({dateFmt:'yyyy'})"> <input
						name="grade4" style="height: 25px; background:none; border:1px solid #CCC" type="text" id="grade4"
						onclick="WdatePicker({dateFmt:'yyyy'})"><br> 领票开始时间<br>
					<input name="starttime" type="text"  style="height: 25px; background:none; border:1px solid #CCC" id="starttime"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"><br>
					领票截止时间<br> <input name="stoptime" type="text" style="height: 25px; background:none; border:1px solid #CCC" id="stoptime"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})"><br>备注<br> <input name="lecNote" type="text" id="lecNote" style="height: 25px; background:none; border:1px solid #CCC"><br>
					<br> <input type="button" value="修改" onclick="sdf()"
						style="border:1px solid; border-color:#ccc; height: 28px; width: 70px; font-size: 22px;">
				</form>

			</div>
			<div style="font-size: 14px; margin-left: 100px;">
				<span id="online">当前在线人数:</span> <span style="margin-left: 150px">Copyright
					&copy; 2013 经济管理学院 北京市海淀区清华东路35号 邮编：100083</span>
			</div>
		</div>
	</div>


</body>
</html>
